﻿// See https://aka.ms/new-console-template for more information

string s = "abcabacbb";
int n = 1;
for (int i = 0; i < s.Length; i++)
{
    int m = 0;
    for (int j = 0; j <= i; j++)
    {
        if (j!=i&&s[j] == s[i])
        {                       
            break;
        }
        m++;
    }   
    n = m > n ? m : n;
}
Console.WriteLine(n);

static void T2()
{
    ListNode node1 = new ListNode(9,
        new ListNode(9,
        new ListNode(9,
        new ListNode(9,
        new ListNode(9,
        new ListNode(9,
        new ListNode(9)))))));
    ListNode node2 = new ListNode(9,
        new ListNode(9,
        new ListNode(9,
        new ListNode(9))));

    ListNode node = AddTwoNumbers(node1, node2);

    while (node != null)
    {
        Console.WriteLine(node.val);
        node = node.next;
    }
}
static ListNode AddTwoNumbers(ListNode n1, ListNode n2)
{
    if (n1 == null && n2 == null)
    {
        return null;
    }

    int v1 = n1 != null ? n1.val : 0;
    int v2 = n2 != null ? n2.val : 0;
    int v = v1 + v2;
    ListNode next = AddTwoNumbers(n1 != null ? n1.next : null, n2 != null ? n2.next : null);
    if (v < 10)
    {
        return new ListNode(v, next);
    }
    else
    {
        return new ListNode(v % 10, AddTwoNumbers(new ListNode(v / 10), next));
    }
}
public class ListNode
{
    public int val;
    public ListNode next;
    public ListNode(int val = 0, ListNode next = null)
    {
        this.val = val;
        this.next = next;
    }
}